Leena Sonpethkar
January 31, 2021
The rubric contains the following two questions:
library(plotly)## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(ggplot2)
library(tidyr)
data(diamonds)
dfDiamond <- diamonds %>%
group_by(cut, color) %>%
summarise(price = sum(price))
Sys.setenv("plotly_username"="leena-sonpethkar")
Sys.setenv("plotly_api_key"="OAPcWxwCLiUGNyeYvwGY")
pl <- plot_ly(dfDiamond, x = ~color, y = ~price, color = ~cut, type="bar") %>%
layout(title = "Diamond price based on Cut by Colors", xaxis=list(title="Cut"), yaxis=list(title="Price"))
pl